package com.smarth.zhizulian.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;

import com.gyf.barlibrary.ImmersionBar;
import com.smarth.zhizulian.R;
import com.smarth.zhizulian.adapter.ViewPagerAdapter;
import com.smarth.zhizulian.app.BaseActivity;
import com.smarth.zhizulian.app.BaseConfig;
import com.smarth.zhizulian.utils.CommonUtils;
import com.smarth.zhizulian.utils.SPUtils;
import com.smarth.zhizulian.view.UnScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 18865 on 2018/1/17.
 */

public class GuideActivity extends BaseActivity {
    @BindView(R.id.vp_viewpager)
    UnScrollViewPager vpViewpager;
    private static final String INTENT_LOGINTYPE = "INTENT_LOGINTYPE";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guide);
        ButterKnife.bind(this);
        init();
    }

    private void init() {
//        SPUtils.saveBoolean(BaseConfig.SP.ONCE_LOGIN, true);
        LayoutInflater inflater = LayoutInflater.from(mContext);
        List<View> views = new ArrayList();
        View guide1 = inflater.inflate(R.layout.item_guide1, null);
        guide1.findViewById(R.id.iv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                vpViewpager.setCurrentItem(1);
            }
        });
        View guide2 = inflater.inflate(R.layout.item_guide2, null);
        guide2.findViewById(R.id.iv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                vpViewpager.setCurrentItem(2);
            }
        });
        View guide3 = inflater.inflate(R.layout.item_guide3, null);
        guide3.findViewById(R.id.iv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                vpViewpager.setCurrentItem(3);
            }
        });
        View guide4 = inflater.inflate(getIntent().getIntExtra(INTENT_LOGINTYPE, 0) == 1 ? R.layout.item_guide4 : R.layout.item_guide5, null);
        guide4.findViewById(R.id.iv_ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CommonUtils.copyToClipboard(mContext, "BZ1226372200");
                GuideActivity.this.finish();
            }
        });
        views.add(guide1);
        views.add(guide2);
        views.add(guide3);
        views.add(guide4);
        vpViewpager.setAdapter(new ViewPagerAdapter(mContext, views));
    }

    @Override
    protected void initStatusBar() {
        ImmersionBar.with(this)
                .transparentStatusBar()
                .statusBarDarkFont(false)
                .fitsSystemWindows(false)
                .init();
    }

    public static void open(Context context, int loginType) {
        Intent i = new Intent(context, GuideActivity.class);
        i.putExtra(INTENT_LOGINTYPE, loginType);
        context.startActivity(i);
    }
}
